package com.example.email.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MailexplainMapper {

    /**
     * 改变邮件的状态(邮件状态  0:收件箱 1:删除 2:彻底删除3:已发送 4:草稿箱 5:举报(放入垃圾箱))
     *
     * @param ids
     * @return
     */
    @Update("<script> " +
            "UPDATE mailexplain\n" +
            " set  mailstatus=#{mailstatus}\n" +
            " WHERE  mailnumber in\n" +
            " <foreach collection=\"array\" item=\"mailnumber\" index=\"index\"  open=\"(\" separator=\",\" close=\")\">\n" +
            " #{mailnumber}\n" +
            " </foreach>" +
            "</script>")
    int updateMailStatus(@Param("mailstatus") int mailstatus,int[] ids);



    /**
     * 将全部的邮件变为已读状态
     * @return
     */
    @Update("UPDATE mailexplain SET ifRead=1 ")
    int updateIfRead1();


    /**
     * 改变邮件是否已读
     * @param ifRead
     * @param ids
     * @return
     */
    @Update("<script>" +
            " UPDATE mailexplain\n" +
            " set  ifRead=#{ifRead}\n" +
            " WHERE  mailnumber in\n" +
            " <foreach collection=\"array\" item=\"mailnumber\" index=\"index\"  open=\"(\" separator=\",\" close=\")\">\n" +
            " #{mailnumber}\n" +
            " </foreach>" +
            "</script>")
    int updateIfReadById(@Param("ifRead") int ifRead, int [] ids);

    /**
     *  改变邮件是否为星标邮件
     * @param ifStartMarker
     * @param ids
     * @return
     */
    @Update("<script>" +
            " UPDATE mailexplain\n" +
            " set  ifStartMarker=#{ifStartMarker}\n" +
            " WHERE  mailnumber in\n" +
            " <foreach collection=\"array\" item=\"mailnumber\" index=\"index\"  open=\"(\" separator=\",\" close=\")\">\n" +
            " #{mailnumber}\n" +
            " </foreach>" +
            "</script>")
    int updateIfStartMarker(@Param("ifStartMarker")int ifStartMarker,int [] ids);


}
